package main

import (
	"DBModel"
	"GameLogic"
	"GameLogic/GameTable"
	"SGNet"
	"Servers"
	"misc/seelog"
	"runtime"
	corecfg "utils/config"

	"GameLogic/AIRobot"

	"git.oschina.net/yangdao/SGLisp"
)

func main() {
	initlog()
	seelog.Info(runtime.NumCPU())
	runtime.GOMAXPROCS(runtime.NumCPU())
	initGame()
	Servers.RunServers()
	SGNet.Run()
}

func initlog() {
	logger, err := seelog.LoggerFromConfigAsFile("seelog.xml")
	if err != nil {
		seelog.Critical("err parsing config log file", err)
		return
	}
	seelog.ReplaceLogger(logger)
}

func initGame() {
	SGLisp.InitRuntime()
	AIRobot.SetScriptPath(`../../Public/GameTable/AI/robot_ai.clj`)
	AIRobot.AIRobot.Load()
	GameTable.Load(`../../Public/GameTable/`)
	GameLogic.LoadGameLogic()
	DBModel.Start()
	corecfg.Load()
}
